//
//  CommonSelectiveAlertViewController.m
//  Merchants
//
//  Created by Yigol on 2018/5/21.
//  Copyright © 2018年 yida. All rights reserved.
//

#import "CommonSelectiveAlertViewController.h"

@interface CommonSelectiveAlertViewController ()

@property (weak, nonatomic) IBOutlet UIView *contentView;

@property (weak, nonatomic) IBOutlet UILabel *messageLabel;

@property (weak, nonatomic) IBOutlet UIButton *firstButton;

@property (weak, nonatomic) IBOutlet UIButton *secondButton;

@end

@implementation CommonSelectiveAlertViewController


+ (instancetype)loadController {
    NSBundle *bundle = [NSBundle mainBundle];
    CommonSelectiveAlertViewController *vc = [[UIStoryboard storyboardWithName:@"Common" bundle:bundle] instantiateViewControllerWithIdentifier:NSStringFromClass(self)];
    vc.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
    vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    return vc;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.contentView.layer.cornerRadius = 8;
    self.contentView.clipsToBounds = true;
    self.contentView.backgroundColor = [UIColor whiteColor];
}

- (void)setMessages:(NSString *)messages {
    _messages = messages;
    self.messageLabel.text = self.messages;
}

- (void)setFirstHandlerName:(NSString *)firstHandlerName {
    _firstHandlerName = firstHandlerName;
    [self.firstButton setTitle:firstHandlerName forState:UIControlStateNormal];
}

- (void)setSecondHandlerName:(NSString *)secondHandlerName {
    _secondHandlerName = secondHandlerName;
    [self.secondButton setTitle:secondHandlerName forState:UIControlStateNormal];
}



- (IBAction)firstAction:(id)sender {
    
    [self dismissViewControllerAnimated:true completion:^{
        if (self.firstHandler) {
            self.firstHandler();
        }
    }];
}

- (IBAction)secondAction:(id)sender {
    
    [self dismissViewControllerAnimated:true completion:^{
        if (self.secondHandler) {
            self.secondHandler();
        }
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
